package com.pe.pgn.clubpgn.domain;

import java.math.BigDecimal;
import java.util.Calendar;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Type;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * @author Edwin Farfan
 *
 */
@Entity
@Table(name = "clpm_stock_almacen_catalogo")
public class ClpmStockAlmacenCatalogo extends CamposAuditoria {
	
	private static final long serialVersionUID = -617214410690730095L;
	private Long id;
	private ClpdArticulo clpdArticulo;
	private ClpbAlmacen clpbAlmacen;
	private ClpmCatalogo clpmCatalogo;
	private BigDecimal vaCantidad;
	private BigDecimal vaComprometido;
	private BigDecimal vaStockCatalogo;
	private BigDecimal vaStockCatalogoEspejo;
	private boolean stStockAlmacenCatalogo;
	private ClprPremioCatalogo clprPremioCatalogo;
	
	
	private Long coArticulo;
	private Long coAlmacen;
	private Long coCatalogo;
	private Long coPremioCatalogo;
	
    @Id
    @Column(name="id")
    @SequenceGenerator(name="seqstockalmacencatalogo", sequenceName="seq_stock_almacen_catalogo")
    @GeneratedValue(generator="seqstockalmacencatalogo")
	public Long getId() {
		return id;
	}
	
	@ManyToOne(targetEntity = ClpdArticulo.class)
    @JoinColumn(name="co_articulo")
	public ClpdArticulo getClpdArticulo() {
		return clpdArticulo;
	}
	
	@ManyToOne(targetEntity = ClpbAlmacen.class)
    @JoinColumn(name="co_almacen")
	public ClpbAlmacen getClpbAlmacen() {
		return clpbAlmacen;
	}
	
	@ManyToOne(targetEntity = ClpmCatalogo.class)
    @JoinColumn(name="co_catalogo")
	public ClpmCatalogo getClpmCatalogo() {
		return clpmCatalogo;
	}
	
    @Column(name = "va_cantidad")
	public BigDecimal getVaCantidad() {
		return vaCantidad;
	}
    
    @Column(name = "va_comprometido")
	public BigDecimal getVaComprometido() {
		return vaComprometido;
	}
    
    @Column(name = "va_stock_catalogo")
	public BigDecimal getVaStockCatalogo() {
		return vaStockCatalogo;
	}
    
    @Column(name = "va_stock_catalogo_espejo")
	public BigDecimal getVaStockCatalogoEspejo() {
		return vaStockCatalogoEspejo;
	}
    
    @Column(name = "st_stock_almacen_catalogo", nullable = false)
	@Type(type = "yes_no") 
	public boolean isStStockAlmacenCatalogo() {
		return stStockAlmacenCatalogo;
	}
    
    @ManyToOne(targetEntity = ClprPremioCatalogo.class)
    @JoinColumn(name="co_premio")
	public ClprPremioCatalogo getClprPremioCatalogo() {
		return clprPremioCatalogo;
	}

    
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 17;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (getClass() != obj.getClass())
			return false;
		ClpmStockAlmacenCatalogo other = (ClpmStockAlmacenCatalogo) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return null;
	}
	
	public void setId(Long id) {
		this.id = id;
	}
	public void setClpdArticulo(ClpdArticulo clpdArticulo) {
		this.clpdArticulo = clpdArticulo;
	}
	public void setClpbAlmacen(ClpbAlmacen clpbAlmacen) {
		this.clpbAlmacen = clpbAlmacen;
	}
	public void setClpmCatalogo(ClpmCatalogo clpmCatalogo) {
		this.clpmCatalogo = clpmCatalogo;
	}
	public void setVaCantidad(BigDecimal vaCantidad) {
		this.vaCantidad = vaCantidad;
	}
	public void setVaComprometido(BigDecimal vaComprometido) {
		this.vaComprometido = vaComprometido;
	}
	public void setVaStockCatalogo(BigDecimal vaStockCatalogo) {
		this.vaStockCatalogo = vaStockCatalogo;
	}
	public void setVaStockCatalogoEspejo(BigDecimal vaStockCatalogoEspejo) {
		this.vaStockCatalogoEspejo = vaStockCatalogoEspejo;
	}
	public void setStStockAlmacenCatalogo(boolean stStockAlmacenCatalogo) {
		this.stStockAlmacenCatalogo = stStockAlmacenCatalogo;
	}

	public void setClprPremioCatalogo(ClprPremioCatalogo clprPremioCatalogo) {
		this.clprPremioCatalogo = clprPremioCatalogo;
	}

	@Column(name = "co_usuario_creador", updatable = false, nullable = false, length = 30)
	public String getCoUsuarioCreador() {
		return coUsuarioCreador;
	}

    @Column(name = "da_fecha_creacion", updatable = false, nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(style = "S-")
	public Calendar getDaFechaCreacion() {
		return daFechaCreacion;
	}

	@Column(name = "co_usuario_modificador", length = 30)
	public String getCoUsuarioModificador() {
		return coUsuarioModificador;
	}

    @Column(name = "da_fecha_modificacion")
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(style = "S-")
	public Calendar getDaFechaModificacion() {
		return daFechaModificacion;
	}

    @Transient
	public Long getCoArticulo() {
		return coArticulo;
	}

    @Transient
	public Long getCoAlmacen() {
		return coAlmacen;
	}

    @Transient
	public Long getCoCatalogo() {
		return coCatalogo;
	}

    @Transient
	public Long getCoPremioCatalogo() {
		return coPremioCatalogo;
	}
    
}
